Repository navigation
fix(core): refuse an artifact package cycle as 422 CYCLIC_ARTIFACT_PACKAGES; install-local answers resolver refusals instead of a 500 - #34708
Conversation
…CKAGES; install-local answers resolver refusals at step 1c resolvePluginOrder throws its cycle as PluginOrderCycleError (message unchanged, carries `cycle`); resolveArtifactPackageEntries answers it in the ADR-0112 envelope its sibling refusals carry, with details.cycle. The code is registered in ERROR_CODE_LEDGER under @objectstack/core. install-local's step 1c (the runtime binder's judgements, the first reader of the packages on a real runtime) answers a resolver refusal with that refusal instead of letting it reach the transport as a 500, and declaredRefusalAnswer forwards the refusal's details. Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…wered 422, no longer thrown out of the door Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…tifact-cycle-refusal
…he new pins Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…tifact-cycle-refusal
📓 Docs Drift CheckThis PR changes 5 package(s): 13 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 188 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 3d2259f0007f770784ac1d55f1de5792bac5adee && git checkout 3d2259f0007f770784ac1d55f1de5792bac5adee
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2e29287b9355b406caa3e63ac35c836a59df9704 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88 && git checkout -B drift-repro 2e29287b9355b406caa3e63ac35c836a59df9704 && git merge --no-ff 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88
node scripts/docs-audit/affected-docs.mjs --json 2e29287b9355b406caa3e63ac35c836a59df9704
|
…tifact-cycle-refusal
…the packages-reader suite, ledgered as mock-replacement Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…tifact-cycle-refusal
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review: |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 8490dc5 · 2026-11-17T08:42Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmTHGRTjPqZAcBuo9WH 席位核对L1 first review · ACCEPT · head Checklist (read on GitHub at this head, not from the report)
Residual (code-read, no change asked)
Owed after this
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Inputs read: card #34574 body and all 7 comments (claim 6939731523, amendments 6939909352 and 6941981971, the three dev reports), PR #34708 body, its 17-file list and 3 comments, the net diff against merge-base ① Derived judgments
② Semver levelClause-②: yes (widening) — correct. The ledger header rules that registering a code widens the published error-code face, and the new export widens
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
Nits, none affecting correctness or the contract; all are prose in code files, so they are left as accepted deviations or a follow-up card, not fixed on this head:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Seat record · 2026-11-17T08:51Z · Head-sha: 8490dc5 维护者速读
席位意见:同意合并。把不透明的 500 换成说清原因的 422,作者和 AI 都能直接看到是哪个环;新错误码名由席位按既有命名定下,只加不减。 席位核对
|
Fixes #34574
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
CYCLIC_ARTIFACT_PACKAGES,details.cycle列出环上的包。另外,本地安装在真实运行时下遇到制品解析器的其它三种拒绝时,也按各自的 422 回答,不再回不透明的 500。packages写错了。packages/cloud-connection/src/marketplace-install-local-plugin.ts(1c 步新增的拦截,以及declaredRefusalAnswer转发details)、packages/core/src/artifact-packages.ts(环如何变成 422)、packages/spec/src/api/error-code-ledger.zod.ts(新错误码的登记行)。pnpm --filter @objectstack/cloud-connection exec vitest run src/marketplace-install-local-resolver-refusal-real-runtime.test.ts,预期 5 个用例全部通过:环、packages不是数组、包 id 重复这三种都回 422 和各自的错误码,合法的组合制品照常装上(200)。What changes
@objectstack/coreresolvePluginOrdernow throws a cycle asPluginOrderCycleError. This is a new exportedErrorsubclass with acycleproperty listing the names along the cycle: each depends on the next, and the first is repeated last. The message is still[Kernel] Circular dependency detected: NAME, and the error carries nocodeorstatus, so kernel boot and the other callers of the sorter see no change.resolveArtifactPackageEntriesreads the cycle off that error, not off a second walk of the graph. It refuses with the envelope its sibling refusals use:code: 'CYCLIC_ARTIFACT_PACKAGES',status: 422anddetails: { cycle }. The message names the cycle as"a" -> "b" -> "a"and still containsCircular dependency detected. Any other throw from the sorter is rethrown unchanged.@objectstack/spec:CYCLIC_ARTIFACT_PACKAGESis registered inERROR_CODE_LEDGERunder@objectstack/core, beside its three siblings, using the seat's ledger text. The generated API references were regenerated withcheck:generated --fix; onlycheck:docswas stale:content/docs/references/api/{error-code-ledger,contract,automation-api}.mdx.@objectstack/cloud-connection(POST /api/v1/marketplace/install-local)declaredRefusalAnswer. Steps 2a, 2b and 2c″ already did this. An undeclared throw is still rethrown.500 INTERNAL_ERROR.declaredRefusalAnswernow also forwards the refusal's owndetails, which is how a cycle'sdetails.cyclereaches the client.Errorare corrected indev-i18n.tsandruntime/src/artifact-collections.ts. Both are comment-only, so those packages get no changeset entry.scripts/driver-memory-census.ledger.jsongains onemock-replacementrow, fordev-i18n-packages-reader.test.ts. That suite now replaces@objectstack/driver-memorywith a not-found-throwingvi.mock, as five sibling plugin-dev harnesses do. Every DevPlugin boot in the file passesdriver: false, so the real driver is never loaded. The mock exists becausecheck:test-source-aliasasks an edited test that reachesdev-plugin.ts's lazy driver import either to pay that load at collection or to mock it. The file's old comment forbidding a mock is rewritten to say why a replacement mock is not a consumer. The seat approved this in amendment 6941981971.Tests
packages/cloud-connection/src/marketplace-install-local-resolver-refusal-real-runtime.test.tsdrives the real install-local handler.422 CYCLIC_ARTIFACT_PACKAGESwithdetails.cycle.packages: 'not-a-list'answers422 INVALID_ARTIFACT_PACKAGES.422 DUPLICATE_ARTIFACT_PACKAGE.collectJobsWithoutBody.describein the install-local: an artifact the resolver refuses answers 503 "retry once the database answers" instead of the resolver's 422 #34432 file because that file mocks@objectstack/runtimefor the whole file.artifact-packages.test.tscovers a two-package cycle (code, status,details.cycle, the message path) and a cycle path that skips packages outside the cycle and ignores an external dependency. Its control is the same packages without the closing edge, which resolve in dependency order.plugin-order.test.tscoversPluginOrderCycleError's path, unchanged message and absentcode/status, and a self-dependency.marketplace-install-local-resolver-refusal-34432.test.ts: its cycle case pinned the cycle as an undeclared throw that is rethrown. It now pins the declared422 CYCLIC_ARTIFACT_PACKAGESanddetails.cycleunder that file's runtime mock, where step 2a reaches the resolver first. The rethrow leg has no other producer: the resolver's only remaining non-envelope throws arePlugin not foundandDependency not found, and neither is reachable throughoptionalDependencies. The 503 control (an unreadable table) is unchanged.dev-i18n-packages-reader.test.ts: its cycle case pinnedcodeandstatusas undefined. It now pinsCYCLIC_ARTIFACT_PACKAGES, 422 anddetails.cycle. The memory driver is now a replacement mock (see What changes).marketplace-install-local-namespace-gate-33922.test.ts, case "UNMOVED — an artifact MEMBER's refused namespace...": this case boots the real runtime and pinned the resolver'sINVALID_ARTIFACT_PACKAGE_ENTRYas a throw out of the handler, which is the step-1c escape this PR closes. It now asserts the answered 422 with the same code and sentence, ADR-0112 envelope-clean.Test runs (b1dc2a6, the last code commit; 8490dc5 adds only a merge of ui/ files from main)
turbo run build, under the verify lock (VERDICT command-exit 0):check:generated: 14/14 up to date.test: Test Files 10/10, Tests 89/89.plugin-order+artifact-packages: Test Files 2/2, Tests 42/42.typecheckfor plugin-dev and cloud-connection: exit 0.typecheckfor core, cloud-connection, plugin-dev, spec and runtime: exit 0.test: 151 files, 3611 tests, all passed.test: 10 files, 89 tests, all passed.test: 847 files, 27154 passed, 1 todo.artifact-load-path+package-source-stamp: 2/2 files, 26/26 tests.test: 1 failed of 1308. That was the namespace-gate case named above; after its move the file reads 15/15.Ablations, one per behaviour (scripts/ablation-replace.mjs, anchor hit 1, mutation landed, restore proven blob == HEAD and git diff HEAD empty)
Every mutated file is read from source by the suite that runs, so no dist preflight is needed. The core suites import their own src. The cloud-connection suites import the handler by relative path; it reads
@objectstack/corefrom dist, which was built from this head.artifact-packages.ts: the cycle rethrown bare (throw err;). Core: 2 failed / 40 passed, the two cycle cases.plugin-order.ts: the sorter throws the old bareError. Core: 4 failed / 38 passed, the twoPluginOrderCycleErrorcases and the two resolver cycle cases.marketplace-install-local-plugin.ts: step 1c's call moved ahead of itstry. Cloud-connection: 3 failed / 7 passed, the real-runtime cycle, not-a-list and duplicate cases. The control and the mocked-runtime file stay green.declaredRefusalAnswer: thedetailsspread deleted. Cloud-connection: 2 failed / 8 passed, thedetails.cycleassertions in both files.Acceptance notes
/api/v1/marketplace/install-localthrough a realHonoHttpServerraw app answered500 {"code":"INTERNAL_ERROR","message":"Internal server error"}. That held both under the install-local: an artifact the resolver refuses answers 503 "retry once the database answers" instead of the resolver's 422 #34432 runtime mock and over the real runtime. Over the real runtime,packages: 'not-a-list'and a duplicate id also answered500 INTERNAL_ERROR: the escape frame isunrunnableCode→ runtimecollectJobsWithoutBody, anddeclaredEnvelopeForThrowrenders no 422.details.cyclefor a cycle.marketplace-install-local-namespace-gate-33922.test.ts(moved by the step-1c fix, named under Tests) andscripts/driver-memory-census.ledger.json(onemock-replacementrow).check:driver-memory-censusandcheck:test-source-aliasboth exit 0 on 8490dc5.check:docswas stale after the ledger row. It was regenerated withcheck:generated --fixintocontent/docs/references/api/error-code-ledger.mdx,contract.mdxandautomation-api.mdx. The other 13 artifacts were up to date, and they still were after the lastorigin/mainmerge, whencheck:generatedwas re-run.resolveArtifactPackageEntries/resolveArtifactPackageOrder(cli namespace utils, core stack-collections, metadata, objectql, plugin-dev, plugin-security, runtime, verify) now see a cycle as the typed refusal.packages/**source reads the old message text./Circular dependency detected/: the dogfooddataset-app-reads-modulecell 3 and coreplugin-order.test.ts:69. The new message keeps that phrase.Verification
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackat head 8490dc5 derived 129 families. All 129 were run, each with stdin from/dev/nulland its exit code captured before any pipe; all 129 exited 0.--ranreconciliation: 129 derived, 129 run, 0 NOT-MEASURED, 0 UNRUN.node scripts/pm/check-governed-merges.mjs --pr 34708at 8490dc5:✅ NOT governed — ordinary queue landing applies to a PR with exactly this file list.check:skill-examples,check:dual-build-cjs-loadsandcheck:dts-closurerefused on build prerequisites, which a full build cleared.check:test-source-aliasandcheck:driver-memory-censuswere each red once, cleared by the two test edits and the ledger row above.!and Clause-② has no(narrowing)arm.Generated by Claude Code